package com.glodon.paas.job.extend.spring;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter;

public class NoViewAnnotationMethodHandlerAdapter extends AnnotationMethodHandlerAdapter {
    public static final String NO_VIEW = "NO_VIEW";

    @Override
    public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler)
            throws Exception {
        ModelAndView mav = super.handle(request, response, handler);
        if (mav != null && !mav.hasView()) {
            request.setAttribute(NO_VIEW, true);
        }
        return mav;
    }
}
